#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#include"sort.h"
static int cmp_int(const void * p1, const void * p2);
static int cmp_char(const void * p1, const void * p2);
static int cmp_string(const void * p1, const void * p2);
static void pri_int(const void *p);

int main(int argc, char *argv[])
{
	int arr1[] = {3,4,5,2,1,9,8,66};
	int len = sizeof(arr1) / sizeof(int);

	char arr2[] = "ahfslkghflabc";
	
	bullle_sort(arr1, len, sizeof(int), cmp_int);
	show_arr(arr1, len, sizeof(int), pri_int);
	printf("\n");

	bullle_sort(arr2, strlen(arr2), sizeof(char), cmp_char);
	puts(arr2);


	bullle_sort(argv, argc, sizeof(char *), cmp_string);

	for(int i = 1; i < argc; i++){
		printf("%s ", argv[i]);
	}
	return 0;
}

static int cmp_int(const void * p1, const void * p2){
	const int *m1 = (const int *)p1;
	const int *m2 = (const int *)p2;

	return *m1 - *m2; 
}

static int cmp_char(const void * p1, const void * p2){
	const char *m1 = (const char *)p1;
	const char *m2 = (const char *)p2;

	return *m1 - *m2; 
}


static int cmp_string(const void * p1, const void * p2){
	char **m1 = (char **)p1;
	char **m2 = (char **)p2;

	return strcmp(*m1, *m2); 
}

static void pri_int(const void *p){
	const int * q = p;
	printf("%d ", *q);
}

